package com.example.demo.controller;

import com.example.demo.pojo.Two;
import com.example.demo.pojo.TwoDto;
import com.example.demo.service.TwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Classname TwoController
 * @Description TODO
 * @Date 2023/5/20 9:58
 * @Created by Zh_Cn
 */
@RestController
@RequestMapping("/information")
public class TwoController {
    @Autowired
    TwoService twoService;
    @Cacheable(cacheNames = "getprice")
    @GetMapping("/prices")
    public Map<String,Integer> getprice(){
        return twoService.getprices();
    }
    @Cacheable(cacheNames = "getrainbow")
    @GetMapping("/rainbow")
    public List<TwoDto> getrainbow(@RequestParam(value = "type",defaultValue = "0")
                                               Integer type){
        return twoService.getrainbow(type);
    }

    @Cacheable(cacheNames = "getTypeAndPrice")
    @GetMapping("/gettype/{start}/{end}")
    public Map<String,Integer> getTypeAndPrice(@PathVariable Long start,@PathVariable Long end){
        return twoService.getTypeAndPrice(start,end);
    }

}
